﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;

namespace YJKCopyModel.Demo
{
	public class UseRequestMaker : IRequestMaker
	{
		public UseRequestMaker(UIDocument inputUIDoc)
		{
			this.useuiDoc = inputUIDoc;
		}

		public List<InputRequest> GetAllInputRequest()
		{
			return this.m_lstRequestes;
		}

		public bool IfBreak
		{
			get
			{
				return true;
			}
		}

		public bool IfEndCommand
		{
			get
			{
				return false;
			}
		}

		public bool IfCancel
		{
			get
			{
				return true;
			}
		}

		public void CloseFrom()
		{
		}

		public void PrepareRequest()
		{
			IList<Element> list = this.useuiDoc.Selection.PickElementsByRectangle("框选模型线直线");
			List<Line> list2 = new List<Line>();
			foreach (Element element in list)
			{
				bool flag = element is ModelLine;
				if (flag)
				{
					Line item = (element as ModelLine).GeometryCurve as Line;
					list2.Add(item);
				}
			}
			List<ICadElement> list3 = new List<ICadElement>();
			foreach (Line thisCurve in list2)
			{
				list3.Add(new LineElement
				{
					ThisCurve = thisCurve
				});
			}
			this.m_lstRequestes = new List<InputRequest>();
			InputRequest inputRequest = new UseInputRequest();
			inputRequest.SelectDataMap.Add("wallLine", list3);
			this.m_lstRequestes.Add(inputRequest);
		}

		private List<InputRequest> m_lstRequestes = new List<InputRequest>();

		private UIDocument useuiDoc;
	}
}
